import 'package:flutter/material.dart';

class TopTabBar extends StatefulWidget {
  @override
  final List tabList;
  final TabController controller;
  TopTabBar({
    Key key,
    @required this.tabList,
    @required this.controller
  }):super(key:key);
  @override
  TopTabBarState createState() => TopTabBarState();
}

class TopTabBarState extends State<TopTabBar>{
  @override
  Widget build(BuildContext context) {
    return TabBar(
      isScrollable: true,
      //是否可以滚动
      controller: widget.controller,
      labelColor: Color(0xff248bfe),
      unselectedLabelColor: Color(0xff666666),
      labelStyle: TextStyle(fontSize: 16.0),
      tabs: widget.tabList.map((item) {
        return Tab(
          text: item["title"],
        );
      }).toList(),
      onTap:(index){
        print(index);
      },
    );
  }
}